package com.yidu.t299.service.ljc.impl;
import com.yidu.t299.dao.ljc.InstoreroomMapper;
import com.yidu.t299.domain.ljc.Instoreroom;
import com.yidu.t299.service.ljc.InstoreroomBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 刘建常
 * @version 1.0
 * @description
 * @date:2023/3/20 11:25
 */
@Service
@Transactional
public class InstoreroomBizImpl implements InstoreroomBiz {
    @Autowired
    private InstoreroomMapper instoreroomMapper;

    @Override
    public int deleteByPrimaryKey(Integer inId) {
        return instoreroomMapper.deleteByPrimaryKey(inId);
    }

    @Override
    public int insert(Instoreroom record) {
        return instoreroomMapper.insert(record);
    }

    @Override
    public Instoreroom selectByPrimaryKey(Integer inId) {
        return instoreroomMapper.selectByPrimaryKey(inId);
    }

    @Override
    public List<Instoreroom> selectByPage(int rows, int page, String condition) {
        return instoreroomMapper.selectByPage(rows, page, condition);
    }

    @Override
    public int selectCount(String condition) {
        return instoreroomMapper.selectCount(condition);
    }

    @Override
    public int updateByPrimaryKey(Instoreroom record) {
        return instoreroomMapper.updateByPrimaryKey(record);
    }

    @Override
    public String getCondition(Instoreroom record) {
        // 定义条件字符串变量，初始值为空格字符串
        String condition = " ";
        // 如果校区对象为空，则直接返回空条件字符串
        if (record == null) {
            return condition;
        }
        // 如果校区编号不为空(如果是基本类型就直接判断!=0)
        if (record.getInId() != null) {
            condition += " and in_id = " + record.getInId();
        }

        if (record.getInName() != null && record.getInName().trim().length() != 0) {
            condition += " and in_name like '%" + record.getInName()+"%'";
        }

        // 如果校区名称不为空
        if (record.getInPrice() != null) {
            condition += " and in_price like '%" + record.getInPrice() + "%'";
        }

        if (record.getInNumber() != null) {
            condition += " and in_number like '%" + record.getInNumber() + "%'";
        }

        if (record.getAdviceNum() != null) {
            condition += " and advise_number like '%" + record.getAdviceNum() + "%'";
        }

        if (record.getStockId() != null) {
            condition += " and stock_id like '%" + record.getStockId() + "%'";
        }

        if (record.getBookerId() != null) {
            condition += " and booker_id like '%" + record.getBookerId() + "%'";
        }

        if (record.getInDate() != null && record.getInDate().trim().length() != 0) {
            condition += " and in_date like '%" + record.getInDate() + "%'";
        }
        // 返回条件字符串
        return condition;
    }
}
